import java.io.*;

public class FileStreamTest {
    static public void main(String [] args) throws Exception {
        File file = new File("./file.test");
        FileInputStream is = new FileInputStream(file);

        /*
         * int ch;
         * while ((ch = is.read()) != -1) {
         *     System.out.print((char)ch);
         * }
         */

        byte [] data = new byte[(int)file.length()];
        is.read(data);
        is.close();

        for (byte ch : data) {
            System.out.print((char)ch);
        }
        // System.out.printf("hello");

        // FileOutputStream os = new FileOutputStream(file, true);
        FileOutputStream os = new FileOutputStream(FileDescriptor.out);
        os.write("hello".getBytes(), 2, 3);

        os.close();
    }
}
